import { View, Text } from "@tarojs/components";
import { AtIcon } from "taro-ui";
import "./index.scss";

export default function ({
  title,
  subTitle = "",
  rightText = "",
  onHandleRight = () => {},
}) {
  const _onClick = () => {
    onHandleRight && onHandleRight();
  };
  return (
    <View className="title-section">
      <View className="left-text">
        <Text className="main-title">{title}</Text>
        <Text className="sub-title">{subTitle}</Text>
      </View>
      {rightText && (
        <View className="right-text" onClick={_onClick}>
          {rightText}
          <AtIcon value="chevron-right" size="14" color="#F00" />
        </View>
      )}
    </View>
  );
}
